﻿using softpower.forms.ui.Stock;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace softpower.forms.ui
{
    public partial class FrmSoftpowerMain : Form
    {

        private int childFormNumber = 0;



        public FrmSoftpowerMain()
        {
            InitializeComponent();
        }



        #region outras funcionalidades

        private void FrmSoftpowerMain_Load(object sender, EventArgs e)
        {
            //Cor do fundo MDI
            foreach (Control control in this.Controls)
            {
                if (control is MdiClient)
                {
                    control.BackColor = Color.SteelBlue;
                    break;
                }
            }
        }



        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        }




        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }



        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }



        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }



        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }



        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }



        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }



        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }



        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }



        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }


        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        #endregion




        private void MenuTipoProduto_Click(object sender, EventArgs e)
        {
            esconderBotoes();
            FrmProduto frm = null;
            frm = FrmProduto.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }


        private void MenuProduto_Click(object sender, EventArgs e)
        {
            esconderBotoes();
            FrmProduto frm = null;
            frm = FrmProduto.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }


        public void esconderBotoes()
        {
            btnStock.Visible = false;
            btnFacturacao.Visible = false;
            btnGestao.Visible = false;
        }


        public void mostrarBotoes()
        {
            btnStock.Visible = true;
            btnFacturacao.Visible = true;
            btnGestao.Visible = true;
        }



        public void enviarBotoesTras()
        {
            btnStock.SendToBack();
            btnFacturacao.SendToBack();
            btnGestao.SendToBack();
        }




        public void EnviarBotoesFrente()
        {
            btnStock.BringToFront();
            btnFacturacao.BringToFront();
            btnGestao.BringToFront();
        }



        private void MenuFornecedor_Click(object sender, EventArgs e)
        {
            esconderBotoes();
            frmFornecedor frm = null;
            frm = frmFornecedor.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }



        private void MenuUtilizadores_Click(object sender, EventArgs e)
        {
            esconderBotoes();
            frmCriarUtilizadores frm = null;
            frm = frmCriarUtilizadores.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }





        private void MenuVenda_Click(object sender, EventArgs e)
        {
            esconderBotoes();
            frmCompra frm = null;
            frm = frmCompra.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }

        private void utilizadoresXGruposToolStripMenuItem_Click(object sender, EventArgs e)
        {


            esconderBotoes();
            frmUsuariosGrupos frm = null;
            frm = frmUsuariosGrupos.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }

        private void administraçãoDeGruposToolStripMenuItem_Click(object sender, EventArgs e)
        {
            esconderBotoes();
            frmCriarGrupo frm = null;
            frm = frmCriarGrupo.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }


        private void paisToolStripMenuItem_Click(object sender, EventArgs e)
        {

            esconderBotoes();
            frmPais frm = null;
            frm = frmPais.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }

        private void provinciaToolStripMenuItem_Click(object sender, EventArgs e)
        {

            esconderBotoes();
            frmProvincia frm = null;
            frm = frmProvincia.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }

        private void municipioToolStripMenuItem_Click(object sender, EventArgs e)
        {
            esconderBotoes();
            frmMunicipo frm = null;
            frm = frmMunicipo.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }

        private void comunaToolStripMenuItem_Click(object sender, EventArgs e)
        {


            esconderBotoes();
            frmComuna frm = null;
            frm = frmComuna.Instancia();
            frm.MdiParent = this;
            frm.Show();
        }



    }
}
